<?php
/**
 * Created by PhpStorm.
 * User: thanatos
 * Date: 2017/10/30
 * Time: 下午2:00
 */

namespace common\traits;


/**
 * Model 类的扩展方法
 *
 * @package common\traits
 */
trait Model
{
    /**
     * 获取单个错误
     * @param Model $model
     * @return string
     */
    public function getOneErrors(Model $model = null)
    {
        $model = !empty($model) ? $model : $this;
        $errors = $model->getErrors();
        foreach(array_keys($errors) as $v ){
            return $model->getFirstError($v);
        }
    }
    
}